package csl.bluetooth.tools.conn;

import java.sql.*;

/**
 * @author 陈少磊
 * @version 1.0.0
 * @ClassName ConnectTool.java
 * @Description TODO
 * @createTime 2021年03月25日 10:11:00
 */
public class ConnectTool {

//    private final static String URL = "jdbc:mysql://172.26.255.6:3306/ias?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true";
    private final static String URL = "jdbc:mysql://localhost:3306/ias?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true";

    private final static String USER_NAME="root";
//    private final static String PWD="iaspasswordisadmin";
    private final static String PWD = "123";
    private final Connection conn;
    public ConnectTool() throws SQLException, ClassNotFoundException {
        Class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection(URL,USER_NAME,PWD);
    }

    public Connection getConn(){
        return this.conn;
    }

    public void close() throws SQLException {
        try{
            if (this.conn != null){
                conn.close();
            }
        }catch (SQLException e){
            System.err.println("关闭异常!");
        }
    }
}
